<template>
	<view>
		<!-- 1，姓名 -->
		<view class="box">
			<view class="box-left">
				<view class="box-title">
					<text>实名认证名</text>
				</view>
			</view>
			<view class="box-right">
				<input v-model="name" class="box-right-input" />
			</view>
		</view>
		<!-- 2，身份证账号 -->
		<view class="box">
			<view class="box-left">
				<view class="box-title">
					<text>身份证号</text>
				</view>
			</view>
			<view class="box-right">
				<input v-model="idCard" class="box-right-input" />
			</view>
		</view>
		<!-- 3，支付宝手机号 -->
		<view class="box">
			<view class="box-left">
				<view class="box-title">
					<text>支付宝账号</text>
				</view>
			</view>
			<view class="box-right">
				<input placeholder="请输入完整手机号" v-model="phone" type="number" class="box-right-input" />
			</view>
		</view>

		<!-- 4，下一步 -->
		<my-bottom :title="title" @clickBtn="clickBtn"></my-bottom>
	</view>
</template>

<script>
	import myBottom from '@/components/common/my-bottom-btn/my-bottom-btn.vue'

	import {
		queryBindingByIdCard,
		insertBinding
	} from '@/api/http/main/my/community.js'

	export default {
		components: {
			myBottom
		},
		data() {
			return {
				title: '绑定',
				name: '',
				idCard: '',
				phone: '',
				form: {
					name: '',
					idCard: '',
					phone: ''
				}
			}
		},
		methods: {
			clickBtn() {
				if (this.name == '' || this.idCard == '' || this.phone == '') {
					return uni.$showMsg('请填写完整参数');
				}

				this.form.name = this.name
				this.form.idCard = this.idCard
				this.form.phone = this.phone
				var that = this

				queryBindingByIdCard(this.form).then(res => {
					if (res.data.pubInfo.code !== 0) {
						return uni.$showMsg(res.data.pubInfo.message);
					}

					// uni.navigateTo({
					// 	url: '/subpkg/main/my/assets/binding/face-recognition/face-recognition?reqForm=' +
					// 		JSON.stringify(this.form)
					// })

					that.form.photograph = ''
					that.form.typeId = 1
					that.form.typeName = '支付宝'

					insertBinding(that.form).then(result => {
						if (result.data.pubInfo.code !== 0) {
							return uni.$showMsg(result.data.pubInfo.message);
						}
						uni.$showMsg('绑定成功！');
						// return uni.navigateTo({
						// 	url: '/subpkg/main/my/commonly/assets/assets/assets'
						// })
						
						setTimeout(() => {
							uni.navigateTo({
								url: "/subpkg/main/my/assets/assets/assets"
							})
						}, 500)
						// return uni.reLaunch({
						// 	url: "/subpkg/main/my/commonly/assets/assets/assets",
						// 	success: () => {
						// 		//plus.navigator.closeSplashscreen();
						// 	}
						// })
					})

				})

			},
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		width: 92%;
		height: 100rpx;
		margin-left: 4%;
		border-bottom: 1rpx solid #eee;
		display: flex;

		.box-left {
			width: 30%;

			.box-title {
				height: 100rpx;
				line-height: 100rpx;

				text {
					font-size: 32rpx;
				}
			}
		}

		.box-right {
			width: 70%;

			.box-right-input {
				width: 100%;
				height: 60rpx;
				margin-top: 20rpx;
			}
		}


	}
</style>